﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data;
using DapperExtensions;
using Common.Property;
using DapperExtensions.Predicate;

namespace Infrastructure.Dapper
{
    public interface IRepositoryBase<T>
    {
        #region 同步
        T GetById(string id);
        #endregion

        #region 异步
        Task<T> GetByIdAsync(string id);
        Task<IEnumerable<T>> GetByIdsAsync(IList<string> ids);
        Task<IEnumerable<T>> GetAllAsync();
        Task<int> CountAsync(object predicate);
        Task<T> GetFirstOrDefaultAsync(object predicate, IList<ISort> sort = null);
        Task<T> GetFirstOrDefaultHasDeleteAsync(object predicate, IList<ISort> sort = null);
        Task<IEnumerable<T>> GetListAsync(object predicate = null, IList<ISort> sort = null);
        Task<Tuple<IEnumerable<T>, int>> GetPageListAsync(int pageIndex, int pageSize, object predicate = null, IList<ISort> sort = null);
        Task<bool> InsertAsync(T entity, OperatorInfo op);
        Task<bool> InsertBatchAsync(IEnumerable<T> entityList, OperatorInfo op);
        Task<bool> UpdateAsync(T entity, OperatorInfo op);
        Task<bool> UpdateBatchAsync(IEnumerable<T> entityList, OperatorInfo op);
        Task<bool> DeleteAsync(string id, OperatorInfo op);
        Task<bool> DeleteListAsync(object predicate, OperatorInfo op);
        Task<bool> DeleteBatchAsync(IEnumerable<dynamic> ids, OperatorInfo op);
        Task<string> GetNewNoAsync(string tableName, string columnName, string key, int length = 3);
        #endregion


    }
}
